package navigation.wzg.com.navigation.Write;


import android.content.Context;
import android.content.SharedPreferences;

import static android.content.Context.MODE_PRIVATE;

/**
 * Created by WZG on 2017/10/27.
 * 本地文件的读写
 */

public class Shareds {
    public static void Writes(String user,String pwd,Context context){
        SharedPreferences perPreferences = context.getSharedPreferences("wzg", MODE_PRIVATE);
        SharedPreferences.Editor editor = perPreferences.edit();
        editor.putString("username",user);
        editor.putString("password",pwd);
        editor.commit();
    }
    public static String[] Reads(Context context){
        SharedPreferences perPreferences = context.getSharedPreferences("wzg", MODE_PRIVATE);
        String aa[] = {perPreferences.getString("username",""),perPreferences.getString("password","")};
        return aa;
    }
    public static void Writes_username(String user,Context context){
        SharedPreferences perPreferences = context.getSharedPreferences("wzg", MODE_PRIVATE);
        SharedPreferences.Editor editor = perPreferences.edit();
        editor.putString("usernames",user);
        editor.commit();
    }
    public static String[] Reads_username(Context context){
        SharedPreferences perPreferences = context.getSharedPreferences("wzg", MODE_PRIVATE);
        String aa[] = {perPreferences.getString("usernames","")};
        return aa;
    }
    public static boolean Firsttrue(String name,Context context) {
        SharedPreferences perPreferences = context.getSharedPreferences("wzg", MODE_PRIVATE);
        return perPreferences.getBoolean(name, true);
    }
    public static void First(String name, boolean b,Context context){
        SharedPreferences perPreferences = context.getSharedPreferences("wzg", MODE_PRIVATE);
        SharedPreferences.Editor editor = perPreferences.edit();
        editor.putBoolean(name, b);
        editor.commit();
    }
}
